package lew.bing.exp.spr.filters;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * Created by 刘国兵 on 2018/7/28.
 */
public class TestFilter implements Filter {

    private static final Logger logger = LoggerFactory.getLogger(TestFilter.class);

    @Override
    public void init(FilterConfig filterConfig) throws ServletException {

    }

    @Override
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
        logger.info("before filter, uri is => {}", ((HttpServletRequest)(request)).getRequestURI());
        chain.doFilter(request,response);
        int status = ((HttpServletResponse) response).getStatus();
        logger.info("after filter, uri is => {},status is => {}", ((HttpServletRequest)(request)).getRequestURI(),status);
    }

    @Override
    public void destroy() {

    }
}
